//
//  DragImageView.m
//  Mahjong
//
//  Created by 饶首建 on 17/7/20.
//  Copyright © 2017年 com.ikamobile.com. All rights reserved.
//

#import "DragImageView.h"

@implementation DragImageView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    // 拿到UITouch就能获取当前点
    UITouch *touch = [touches anyObject];
    // 获取当前点
    CGPoint curP = [touch locationInView:self];
    // 获取上一个点
    CGPoint preP = [touch previousLocationInView:self];
    // 获取手指x轴偏移量
    CGFloat offsetX = curP.x - preP.x;
    // 获取手指y轴偏移量
    CGFloat offsetY = curP.y - preP.y;
    // 移动当前view
    self.transform = CGAffineTransformTranslate(self.transform, offsetX, offsetY);
}

// 触摸事件被迫打断(电话打来)
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
}
//手抬起的时候调用
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
}

@end
